package com.community.controller;

import com.community.entity.Infos;
import com.community.service.InfoService;
import com.community.util.Result;
import com.community.util.Search;
import com.feng.fengDUtil.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/news")
public class NewsAction {
    @Autowired
    private InfoService infoService;

    @RequestMapping(value = "/list")
    public Result list(Page page, Search search) {
        infoService.query(page,search);
        return Result.success(page);
    }

    @RequestMapping(value = "/setTop")
    public Result dealOrder(String id) {
        infoService.setTop(id);
        return Result.success();
    }

    @RequestMapping(value = "/save")
    public Result save(@RequestBody Infos infos) {
        infoService.saveOrUpdate(infos);
        return Result.success();
    }

    @RequestMapping(value = "/del")
    public Result del(String ids) {
        infoService.deleteByIds(Infos.class,ids);
        return Result.success();
    }
}
